<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions" >
<h:head>
	<title>List Travel Packages</title>
</h:head>
<h:body>
	<h:link value="PERSONAL HOME" outcome="index" />
 	<h:form id="formView">
		<f:event type="preRenderView" listener="#{listTravelPackages.init()}" />
	
        <p:dataTable id="dataTablePackage" var="package" value="#{listTravelPackages.travelPackages}"  
                 paginator="true" rows="15" rowKey="#{package.id}" dblClickSelect="true"
                 selectionMode="single" selection="#{listTravelPackages.selectedTravelPackage}"
                 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink}
                 {PageLinks} {NextPageLink} {LastPageLink}" >
     	
        <p:ajax event="rowSelect" listener="#{listTravelPackages.onTravelPackageRowSelectNavigate}" />
        
        <f:facet name="header">  
            List travel packages
        </f:facet>  
  
        <p:column sortBy="id" headerText="ID">  
            <h:outputText value="#{package.id}" />  
        </p:column>  
  
        <p:column headerText="Description">
          	<p:inputTextarea value="#{package.description}" rows="2" cols="15"
            	readonly="true" autoResize="false" />  
        </p:column>  
  
        <p:column sortBy="startTrip" headerText="Begin date">
            <h:outputText value="#{package.startTrip}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
         <p:column sortBy="endTrip" headerText="End date">
            <h:outputText value="#{package.endTrip}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
        <p:column sortBy="price" headerText="Total price">
            <h:outputText value="#{package.totalPrice} €" />  
        </p:column>
        
        <p:column sortBy="expiryDate" headerText="Expiry">
            <h:outputText value="#{package.expiry}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
        <p:column sortBy="feasibleReservations" headerText="Feasible reservations">
            <h:outputText value="#{package.feasibleReservations}" />  
        </p:column>
        
        <p:column sortBy="type" headerText="Type">
            <h:outputText value="#{package.type}" />  
        </p:column>
        <f:facet name="footer">  
              Total travel packages: #{listTravelPackages.travelPackages.size()}
        </f:facet>
    	</p:dataTable>
	</h:form>
</h:body>
</html>